<!--
*@description 
*@fileName 平台药品库（非医保）
*@author wxl
*@date 2025/02/15 15:29:11
!-->
<template>
   <div class="vue-box">
      <div class="search-card">
         <div class="search-body">
            <el-form :inline="true" :model="formData" class="demo-form-inline">
               <el-form-item label="日期">
                  <el-date-picker type="daterange" v-model="formData.date" format="YYYY-MM-DD" value-format="YYYY-MM-DD" placeholder="请选择"></el-date-picker>
               </el-form-item>
               <el-form-item>
                  <el-button class="btn" type="primary" @click="onSearch">搜索</el-button>
                  <el-button class="btn"  @click="reset">重置</el-button>
               </el-form-item>
            </el-form>
         </div>
      </div>
      <div class="c-card flex1 table-box">
         <div class="table-body">
            <el-table :data="tableData" row-key="fixmedins_code" stripe style="width: 100%;" max-height="400px" @selection-change="handleSelectionChange">
               <el-table-column type="selection" width="55" reserve-selection/>
                <!-- 序号 -->
               <el-table-column
                  label="编号"
                  type="index"
                  width="60"
               ></el-table-column>
               <el-table-column v-for="(item, index) in tableCfg" :key="index" :prop="item.prop" :label="item.label" :width="item.width">
                  <template #default="scope">
                     <span>
                        {{ item.formatter ? item.formatter(scope.row[item.prop]) : scope.row[item.prop] }}
                     </span>
                  </template>
               </el-table-column>
               <!-- <el-table-column fixed="right" label="操作" width="100" align="center">
                  <template #default="scope">
                     <el-button link type="danger" size="small" @click="onOffline(scope.row)" v-if="scope.row.IsOline == 1">下线</el-button>
                     <el-button link type="primary" size="small" @click="onOnline(scope.row)" v-if="scope.row.IsOline == 2">上线</el-button>
                  </template>
               </el-table-column> -->
            </el-table>
         </div>
         <!-- <div class="aicjcsb">
            <div class="margin-top">
               <el-button text type="primary" @click="multOnline">批量上线</el-button>
               <el-button text type="danger" @click="mulOffline">批量上线</el-button>
            </div>
            <table-pagin :page-no="pagin.pageNo" :page-size="pagin.pageSize" :total="pagin.total" @handleCurrentChange="handleCurrentChange" @handleSizeChange="handleSizeChange" />
         </div> -->
         <table-pagin :page-no="pagin.pageNo" :page-size="pagin.pageSize" :total="pagin.total" @handleCurrentChange="handleCurrentChange" @handleSizeChange="handleSizeChange" />
      </div>
      <!-- 提现弹窗 -->
      <el-dialog
         v-model="dialogVisible"
         title="请输入提现金额"
         width="500"
      >
      <el-input v-model="withdrawalAmount" autocomplete="off" />
         <template #footer>
            <div class="dialog-footer">
            <el-button @click="dialogVisible = false">取消</el-button>
            <el-button type="primary" @click="dialogVisible = false">
               提现
            </el-button>
            </div>
         </template>
      </el-dialog>
   </div>
</template>
<script setup name="goods-list">
import { reactive,onMounted, ref } from 'vue'
// import {useRouter} from 'vue-router'
import tablePagin from '@/sa-frame/com/pagin/table-pagin.vue'
import dicts from '@/utils/dict.js'
const totalAmount = ref(0) 
// 提现金额
const withdrawalAmount = ref(0)
const dialogVisible = ref(false)

const formData = reactive({
})
const pagin = reactive({
   pageNo: 0,
   pageSize: 10,
   total: 0,
   server_time: ''
})

const tableCfg = ref([ {
   label: '提现金额',
   prop: 'externalTraceNo',
}, {
   label: '提现位置',
   prop: 'PaymentAmount',
}, {
   label: '提现状态',
   prop: 'StoreName',
},  {
   label: '提现时间',
   prop: 'CreateDT'
}, {
   label: '到账时间',
   prop: 'OnlineInquiryTime'
}])

const tableData = ref([])
// 已选择行
const selectedRows = ref([])

// 组件加载时触发
onMounted(() => {
    f5();
})

// 搜索
function onSearch() {
   pagin.pageNo = 0
   f5()
}
// 重置
function reset() {
   formData.date = ''
   pagin.pageNo = 0
   f5()
}
// 获取账户信息
function getAccountInfo() {
   sa.ajax('/api/fund/accountInfo', {}, function(res) {
      totalAmount.value = res.data.totalAmount
   });
}
// ------------------ 查找数据 ------------------
const f5 = function() {
   let params = {
      pageindex: pagin.pageNo,
      pagesize: pagin.pageSize,
      begintime: formData.date ? formData.date[0]: '',
      endtime: formData.date ? formData.date[1] : ''
   }
   sa.ajax('/api/webOnlineInquiry/takeRecordList', params, function(res) {
      tableData.value = res.data;	// 数据
      pagin.total = Number(res.totalItems);
      pagin.server_time = res.server_time
   });
};
// 表格页码切换
function handleCurrentChange(pageNo) {
   pagin.pageNo = pageNo
   console.log(' pagin.pageNo',pagin.pageNo)
   f5()
}
// 表格size修改
function handleSizeChange(pageSize) {
   pagin.pageSize = pageSize
   f5()
}
// 表格行选择
function handleSelectionChange(val) {
  console.log('handleSelectionChange',val)
  selectedRows.value = val
} 
// 批量上线
function multOnline() {
   sa.confirm('确定批量上线？', function() {

      // sa.ajax('/api/fund/storeInformationList', {
      //    ...formData
      // }, function(res) {
      //    tableData.value = res.data;	// 数据
      //    pagin.total = Number(res.totalItems);
      // }
      // )
   })
}
// 对外开放函数 
defineExpose({f5})
</script>
<style lang="scss" scoped>
.fs30{
   font-size: 30px;
}
.fs28{
   font-size: 28px;
}
.left-amount{
   width: 280px;
   height: 156px;
   border-radius: 8px 8px 8px 8px;
   border: 1px solid #E6E6E6;
   padding: 23px 0 24px 20px;
   margin-top: 20px;
   .icon{
      width: 44px;
      height: 44px;
      margin-right: 18px;
   }
   .btn{
      width: 80px;
      height: 32px;
      background: #F7F7F7;
      border-radius: 5px 5px 5px 5px;
      border: 1px solid #E6E6E6;
   }
}
</style>
